/*
 * ring_bugger.h
 *
 *  Created on: Aug 19, 2024
 *      Author: 31652
 */

#ifndef RING_BUFFER_H_
#define RING_BUFFER_H_

#include <stdio.h>
#include <stdint.h>
#include <string.h>

#define I_RING_BUFFER_SUCCESS     0x01
#define I_RING_BUFFER_ERROR       0x00

typedef struct {
	uint32_t head;
	uint32_t tail;
	uint32_t capacity; // only edit once
	uint32_t size;

	uint8_t* data;
}i_ringbuffer;


uint8_t I_Ring_Buffer_Init(i_ringbuffer* instance, uint8_t* dataBuffer, uint32_t capacity);

// skip max < i_ringbuffer.size
void I_Ring_Buffer_Skip(i_ringbuffer* handle, uint32_t n);
void I_Ring_Buffer_Clear(i_ringbuffer* handle);
uint32_t I_Ring_Buffer_FreeSpace(i_ringbuffer* handle);
uint8_t I_Ring_Buffer_WriteBytes(i_ringbuffer* handle, uint8_t* input, uint32_t n);
uint8_t I_Ring_Buffer_WriteByte(i_ringbuffer* handle, uint8_t input);

uint8_t I_Ring_Buffer_ReadBytes(i_ringbuffer* handle, uint8_t* output, uint32_t n);
uint8_t I_Ring_Buffer_GetByte(i_ringbuffer* handle, uint32_t offset);

void I_Ring_Status(i_ringbuffer* handle);
void I_Ring_Ram(i_ringbuffer* handle);
#endif /* RING_BUFFER_H_ */
